// pages/readWorks/listWorks/index.js
var app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    rws: [],
    user_type: 1,
    prompt: {
      hidden: !0,
      icon: '../../../assets/images/iconfont-order-default.png',
      title: '数据为空',
      text: '暂无任务',
      gurl: '../../pages/home/home',
      gtype: "switchTab"
    }
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var user_type = wx.getStorageSync('user_type');
    this.setData({
      user_type: user_type
    })
    this.getListWorks()
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  getListWorks() {
    var that = this
    const userType = wx.getStorageSync('user_type')
    const usid = wx.getStorageSync('usid');
    wx.showLoading({
      title: '加载中',
    })
    app.wxget({
      url: 'issuedWorks/listMyWorks.html?userType='+userType+"&usid="+usid,
      success: function (res) {
        var rws = res.data
        wx.hideLoading()
        that.setData({
          rws: rws
        })
      }
    })
  },

  toTaskDetail(e) {
      const publishid = e.currentTarget.dataset.publishid
      wx.navigateTo({
        url: '../../readWorks/workDetail/index?publishid=' + publishid
      })
  }

})